<?php 
	class products extends database
	{	
        function show_all_product()
        {
            $data = new database();

            $sql = "select * from tblproduct where status = 1 order by rand()";
            $data->SetQuery($sql);
			$table = $data->LoadAllRow();
			$data->disconnect();
            
			return $table;
        }
		function show_biding_product_by_cate($cate_id)
        {
            $data = new database();

            $sql = "select * from tblproduct where status = 1 and categories_id = {$cate_id}";
            
            
			$data->SetQuery($sql);
			$table = $data->LoadAllRow();
			$data->disconnect();
            
			return $table;
        }
		function show_ending_auction()
        {
            $data = new database();

            $sql = "SELECT *
            		FROM tblproduct, tblmember, tblmemberwon 
 					WHERE tblmemberwon.pro_id = tblproduct.pro_id and tblmemberwon.memid = tblmember.memid and tblproduct.status=0";
            $data->SetQuery($sql);
			$table = $data->LoadAllRow();
			$data->disconnect();
            return $table;
        }
        function show_ending_auction_by_cate($cate_id)
        {
            $data = new database();

            $sql = "select * from tblproduct where status = 0 and categories_id = {$cate_id}";
            $data->SetQuery($sql);
			$table = $data->LoadAllRow();
			$data->disconnect();
            return $table;
        }	
		function product_sold_detail($proid)
		{
			$data = new database();		
			$sql="select tblproduct.pro_name, tblmemberwon.soldfor, tblmemberwon.sold_date, tblmemberwon.bid_used, tblcountry.country_name, tblproduct.pro_prince from tblmemberwon,tblproduct,tblcountry,tblmember
				where tblmemberwon.pro_id = tblproduct.pro_id 
				and tblmemberwon.memid = tblmember.memid
				and tblmember.country_id = tblcountry.country_id
				and tblproduct.pro_id = {$proid}
				ORDER BY tblmemberwon.win_id DESC LIMIT 0,1 ";
			$data->SetQuery($sql);
			$table = $data->LoadOneRow();
			$data->disconnect();
			return $table;
		}	
		function product_bidding_detail($proid)
		{
			$data = new database();		
			$sql="SELECT  SUBSTRING(tblproduct.pro_desc, 1, 50) as pro_desc, tblcountry.country_name, tblproduct.pro_name, tblproduct.pro_prince, tblcategories.categories_name FROM tblproduct, tblcategories, tblcountry WHERE tblcategories.categories_id = tblproduct.categories_id AND tblcountry.country_id = tblproduct.country_id AND pro_id = {$proid}";
			$data->SetQuery($sql);
			$table = $data->LoadOneRow();
			$data->disconnect();
			return $table;
		}
		function get_product_image_by_proid($proid)
		{
			$data = new database();		
			$sql="select pro_image1, pro_image2, pro_image3, pro_image4, pro_image5 from tblproduct where pro_id = {$proid}";
			$data->SetQuery($sql);
			$table = $data->LoadOneRow();
			$data->disconnect();
			return $table;
		}
		function get_all_categories($proid)
		{
			$data = new database();		
			$sql="SELECT * FROM tblcategories";
			$data->SetQuery($sql);
			$table = $data->LoadOneRow();
			$data->disconnect();
			return $table;
		}
        
	}
?>